package cn.openea.perpartner.mpwx.controller;

import cn.openea.perpartner.common.core.web.controller.BaseController;
import cn.openea.perpartner.mpwx.service.IWxMpReplyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;

/**
 * @author Weird077
 * @description TODO
 * @date 2022-06-24 10:18
 */
@Controller
@RequestMapping("/wechat")
public class WxMpReplyController extends BaseController {
    Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    private IWxMpReplyService wxMpReplyService;

    @RequestMapping("/reply")
    @ResponseBody
    public String reply(HttpServletRequest request) throws Exception {
        String signature = request.getParameter("signature");
        String echostr = request.getParameter("echostr");
        String timestamp = request.getParameter("timestamp");
        String nonce = request.getParameter("nonce");
        HashMap<String,Object> params =new HashMap<>();
        params.put("signature",signature);
        params.put("echostr",echostr);
        params.put("timestamp",timestamp);
        params.put("nonce",nonce);
        logger.debug(params.toString());
        return wxMpReplyService.run(params);
    }

}
